
<h3>Viewing Updates</h3>
<h4>Below are all active updates for COTC</h4>
<h4>You currently have <b><?= client_update_count_claimed(); ?></b> update(s) that belong to you</h4>
<table>
	<thead>
		<tr>
			<th>Client</th>
			<th>Project</th>
			<th>Priority</th>
			<th>Date Submitted</th>
			<th>Assigned To</th>
			<th>View</th>
		</tr>
	</thead>
	<tbody>
	<?php
	$sql    = "SELECT
      clients.fname,
      clients.lname,
      projects.p_title,
      updates.priority,
      updates.date_submitted,
      updates.a_id,
      updates.u_id
FROM updates
      INNER JOIN projects ON updates.p_id = projects.p_id
      INNER JOIN clients ON projects.c_id  = clients.c_id
      LEFT JOIN admin ON updates.a_id = admin.a_id

      WHERE completed IS NULL";
	
	$query  = mysql_query($sql) or die(mysql_error());
	$count  = mysql_num_rows($query);
	if($count == 0){
		print "<tr><td><i>No updates at this time. All caught up!</i></td></tr>";
	}else{
		while($row = mysql_fetch_array($query)){
			print '<tr>'; 
			print '<td>'.$row['fname'].' '.$row['lname'].'</td>'; 
			print '<td>'.$row['p_title'].'</td>'; 
			print '<td>'.$row['priority'].'</td>';
			print '<td>'.date('m/d/y', strtotime($row['date_submitted'])).'</td>';
			if($row['a_id'] == NULL){
				print '<td><a href="#">Claim it?</a></td>';

			}else{
				print '<td>'.$row['fname'].'</td>';
			}
			print '<td align="center"><a href="?c=displayupdate&id='.$row['u_id'].'" title="View update for '.$row['p_title'].'" id="'.$row['u_id'].'"><img src="images/page_edit.png" alt="Edit entry!" /></a></td>';
			print '</tr>';
		}
	}
?>
	</tbody>
</table>
